<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<title>会员管理</title>
<%@ include file="../../../common/admin_taglib.jsp" %>
<link rel="stylesheet" type="text/css" href="${ctx}/resources/js/jquery-easyui-1.3.3/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="${ctx}/resources/js/jquery-easyui-1.3.3/themes/icon.css">
<script type="text/javascript" src="${ctx}/resources/js/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
function doEdit(id){
	$("#updateAddressModal_"+id).modal("show");
}

function showDiv(){
	$("#addAddressModal").modal("show");
}
</script>
<style type="text/css">
.partal_item {background:#f3eeaf;padding:5px;}
.partal_item img {width:100%;height:150px;margin-bottom:5px;}
</style>
</head>
<body>

<h1 class="page-title">Shop4j 管理中心</h1>
	<div class="btn-toolbar">
	    <a class="btn btn-primary" a href="javascript:showDiv();"><i class="icon-plus"></i>添加地址</a>
	  	<div class="btn-group"></div>
	</div>
<ul class="breadcrumb">
	 <li><a href="${ctx}/admin/main">管理中心</a><span class="divider">/</span></li>
	 <li><a href="${ctx}/admin/member/list">会员列表</a><span class="divider">/</span></li>
     <li class="active">地址管理</li>
</ul>

	<div class="block">
		<div class="block-heading">
            <span class="block-icon pull-right">
                <a href="#widget2container" data-toggle="collapse">
                	<i class="icon-chevron-down"></i>
                </a>
            </span>
            <a>收货地址列表</a>
        </div>
	</div>
	<div class="well">
		<table class="table">
			<thead>
		    	<tr>
		    		<td>#编号</td>
		    		<td>会员ID</td>
		    		<td>省份</td>
		    		<td>城市</td>
		    		<td>区域</td>
		    		<td>联系人</td>
		    		<td>联系电话</td>
		    		<td>收货地址</td>
		    		<td>邮编</td>
		    		<td>操作</td>
		        </tr>
		     </thead>
		     <tbody>
		     	<c:forEach items="${memberAddress}" var="m">
		     	<tr>
		     		<td>${m.id}</td>
		     		<td>${m.memberId}</td>
		     		<td><label>${m.provinceName}</label></td>
		     		<td>${m.cityName}</td>
		     		<td>${m.districtName}</td>
		     		<td>${m.contactsName}</td>
		     		<td>${m.contactsTelphone}</td>
		     		<td>${m.address}</td>
		     		<td>${m.zipCode}</td>
		     		<td>
		     			<a href="javascript:doEdit(${m.id});">编辑</a>
		     			<a href="${ctx}/admin/member/addressManager/delete/${m.id}&${m.memberId}">删除</a>
		     		</td>
		     	</tr>
		     	</c:forEach>
		     </tbody>
		</table>
	</div>
	<dd:pagination formId="search_form" count="${page.count }" page="${page.page }" curpage="${page.curpage }"></dd:pagination>
	
<!-- 新增 -->	
<div class="modal large hide fade" id="addAddressModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <form class="form-horizontal" id="addAddressForm" method="post" action="${ctx}/admin/member/addressManager/insert">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">
    	<i class="icon-inbox"></i>新增地址
    </h3>
  </div>
  <div class="modal-body">
 		<input type="hidden" name ="memberAddress.memberId" value ="${memberId}">
 		<div class="control-group">
            <label class="control-label">联系人</label>
            <div class="controls">
            	<input type="text" name="memberAddress.contactsName" class="input-large validate" validate="empty">
        	</div>
        </div>
        <div class="control-group">
            <label class="control-label" for="input01">所在地</label>
            <div class="controls">
        		<div id="city_4">
        			<dd:address id="address" districtName="memberAddress.districtId" provinceName="memberAddress.provinceId" cityName="memberAddress.cityId">
					</dd:address>
        			<input type="text" name="memberAddress.address" class="input-large validate" validate="empty">
    			</div>        		    
        	</div>
        </div>
        <div class="control-group">
            <label class="control-label" for="input01">邮编</label>
            <div class="controls">
        		<input type="text" name="memberAddress.zipCode" class="input-small validate" validate="empty">    
        	</div>
        </div>
        
        <div class="control-group">
            <label class="control-label" for="input01">联系电话</label>
            <div class="controls">
        		<input type="text" name="memberAddress.contactsTelphone"  class="input-large validate" validate="empty">    
        	</div>
        </div>
  </div>
  <div class="modal-footer">
  			<input id="deleteConfirm_ok" type="submit" class="btn btn-info" value="保存" />
  			<button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
  </div>
  </form>
</div>


<c:forEach items="${memberAddress}" var="m">
<!-- 编辑 -->	
<div class="modal large hide fade" id="updateAddressModal_${m.id}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <form class="form-horizontal" id="updateAddressForm" method="post" action="${ctx}/admin/member/addressManager/update/${m.id}">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">
    	<i class="icon-inbox"></i>编辑地址
    </h3>
  </div>
  <div class="modal-body">
 		<input type="hidden" name ="memberAddress.id" value ="${m.id}">
 		<input type="hidden" name ="memberAddress.memberId" value ="${m.memberId}">
 		<div class="control-group">
            <label class="control-label">联系人</label>
            <div class="controls">
            	<input type="text" value="${m.contactsName}" name="memberAddress.contactsName" class="input-large validate" validate="empty">
        	</div>
        </div>
        <div class="control-group">
            <label class="control-label" for="input01">所在地</label>
            <div class="controls">
        		<div id="city">
        			<dd:address id="addresses_${m.id}" 
        			districtName="memberAddress.districtId" provinceName="memberAddress.provinceId" cityName="memberAddress.cityId"
        			districtValue="${m.districtId}" provinceValue="${m.provinceId}" cityValue="${m.cityId}"
        			>
					</dd:address>
        			<input type="text" value="${m.address}" name="memberAddress.address" class="input-large validate" validate="empty">
    			</div>        		    
        	</div>
        </div>
        <div class="control-group">
            <label class="control-label" for="input01">邮编</label>
            <div class="controls">
        		<input type="text" value="${m.zipCode}" name="memberAddress.zipCode" class="input-small validate" validate="empty">    
        	</div>
        </div>
        
        <div class="control-group">
            <label class="control-label" for="input01">联系电话</label>
            <div class="controls">
        		<input type="text" value="${m.contactsTelphone}" name="memberAddress.contactsTelphone"  class="input-large validate" validate="empty">    
        	</div>
        </div>
  </div>
  <div class="modal-footer">
  			<input id="deleteConfirm" type="submit" class="btn btn-info" value="保存" />
  			<button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
  </div>
  </form>
</div>
</c:forEach>
</body>
</html>